vis = [0 for i in range(0, 20)]
n = 0
stack = [0 for i in range(0, 20)]
def DFS(depth) :
	global n
	if(depth > n) :
		for i in range(1, n):
			print(stack[i], end = " ")
		print(stack[n])
		return
	
	for i in range(1, n+1):
		if(vis[i] == 0):
			vis[i] = 1
			stack[depth] = i
			DFS(depth + 1)
			vis[i] = 0
	return

n = int(input().split()[0])
DFS(1)
